home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************************
- ;
- ; frac_div.asm
- ;
- ; staff
- ;
- ; 02-21-91
- ;
- ; (C) Texas Instruments Inc., 1992
- ;
- ; Refer to the file 'license.txt' included with this
- ; this package for usage and license information.
- ;
- ;**************************************************************
- *
- * This routine implements fractional division using the SUBC instruction. For
- * this division routine, the absolute value of the denominator must be
- * greater than the absolute value of the numerator. In addition, the
- * calling routine must check to verify that the divisor does not equal 0.
- *
- * The 16-bit dividend is placed in the high accumulator, and the low accumulator
- * is zeroed. The divisor is in data memory.
- *
- DENOM .set 60h
- NUMERA .set 61h
- QUOT .set 62h
- REM .set 63h
- TEMSGN .set 64h
- *
- FRACDIV LDP #0
- LT NUMERA ; Determine sign of quotient.
- MPY DENOM
- SPH TEMSGN
- LACL DENOM
- ABS ; Make denominator and numerator positive.
- SACL DENOM
- LACC NUMERA,16 ; Load high accumulator, zero low accumulator.
- ABS
- *
- * If divisor and dividend are aligned, division can start here.
- *
- RPT #15 ; 16 cycle division. Low accumulator contains
- SUBC DENOM ; the quotient and high accumulator contains the
- ; remainder at the end of the loop.
- *
- BIT TEMSGN,0 ; Test sign of quotient.
- RETCD NTC ; Return if sign positive, else continue.
- SACL QUOT ; Store quotient and remainder during delayed
- SACH REM ; branch.
- *
-
- LACL #0 ; If sign negative, negate quotient.
- RETD
- SUB QUOT
- SACL QUOT
-